<?php
ob_start();
include('config.php');
	require_once 'syslogin/usuario.php';
	require_once 'syslogin/autenticador.php';
	require_once 'syslogin/sessao.php';

	$aut = Autenticador::instanciar();
	$usuario = null;
	if ($aut->esta_logado()) {
		$usuario = $aut->pegar_usuario();
	}
	else {
		$aut->expulsar();
	}

$query = "SELECT * FROM equipamento ORDER BY nome";
$ret = mysql_query($query,$conn) or die(mysql_error());
?>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title">
						<span class="glyphicon glyphicon-tower"></span> <strong>Salas e Equipamentos</strong>
					</h3>
				</div>
				<div class="panel-body">
<?php

$msg = NULL;
if($_REQUEST['msg']) {   
   $msg = $_REQUEST['msg'];
   if($msg == "sucesso") {
      echo '<div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Fechar</span></button>
  <strong><span class="glyphicon glyphicon-ok"></span> Cadastro efetuado com sucesso!</strong></div>';
   } else if($msg == "alteracao") {
      echo '<div class="alert alert-success alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Fechar</span></button>
  <strong><span class="glyphicon glyphicon-refresh"></span> Cadastro alterado com sucesso!</strong></div>';
   } else {
      echo '<div class="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Fechar</span></button>
  <strong><span class="glyphicon glyphicon-warning-sign"></span> O nome informado já existe!</strong></div>';
   }
}
?>
				<p align="right"><a href="index.php?id_=cad_equipamento" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span> Novo</a></p>
			<table class="table table-hover table-condensed table-bordered">
				<thead>
					<tr class="success">
						<th>Salas e Equipamentos</th>
						<th></th>
					</tr>
				</thead>
<?php while($res=mysql_fetch_assoc($ret)) { ?>
				<tbody>
					<tr>
						<td><?php echo $res['nome']; ?></td>
						<td align="center"><a href="index.php?id_=cad_equipamento&id=<?php echo $res['id']; ?>"><span class="glyphicon glyphicon-pencil"></span></a></td>
					</tr>
				</tbody>
<?php }; ?>
			</table>
				</div>
				<div class="panel-footer">
					<small><p class="text-right text-muted">Desenvolvido pela <a href="http://www.ifsertao-pe.edu.br/dgti" target="_blank" title="Coordenação de Tecnologia da Informação - Zona Rural">CTI - Zona Rural</a></p></small>
				</div>
			</div>
		</div>
